#include <iostream>
using namespace std;

typedef int elemType;
typedef struct Node{
    elemType data;
    Node* next;
}Node,*nodep;

typedef struct{
    nodep front;
    nodep rear;
}linkedQueue;

int init(linkedQueue &q){
    q.front = q.rear = new Node;
    q.front->next = NULL;
    return 1;
}

int enqueue(linkedQueue &q,elemType e){
    nodep p = new Node;
    p->data  = e;
    p->next = NULL;
    q.rear->next = p;
    q.rear = p;
    return 1;
}

int deQueue(linkedQueue &q,elemType &e){
    if(q.front == q.rear) return -1;
    nodep p = q.front->next;
    e = p->data;
    q.front->next = p->next;
    if(q.rear == p) q.rear = q.front;
    delete p;
    return 1;

}

int main(){

    linkedQueue q;
    init(q);
    enqueue(q,1);
    enqueue(q,2);
    enqueue(q,3);
    int a ;
    deQueue(q,a);
    cout<<a<<endl;
    deQueue(q,a);
    cout<<a<<endl;
    deQueue(q,a);
    cout<<a<<endl;


    return 0;
}